/*
 * @Description: http 类型
 * @Author: Brian brian@sina.com
 * @Date: 2022-10-08 18:28:02
 * @LastEditors: Brian Brian@gmail.com
 * @LastEditTime: 2024-09-09 18:14:12
 */
import type {
  AxiosError,
  AxiosResponse,
  InternalAxiosRequestConfig,
  Method,
} from 'axios'

export interface resultType {
  accessToken?: string
}

export type RequestMethods = Extract<
  Method,
  'get' | 'post' | 'put' | 'delete' | 'patch' | 'option' | 'head'
>

export interface HttpError extends AxiosError {
  isCancelRequest?: boolean
  errData: {
    code: number
    msg: string
  }
}
export interface HttpRequestConfig extends InternalAxiosRequestConfig {
  beforeRequestCallback?: (request: HttpRequestConfig) => void
  beforeResponseCallback?: (response: HttpResponse) => void
}

export interface HttpResponse extends AxiosResponse {
  config: HttpRequestConfig
}

// export default class Http {
//   request<T>(
//     method: RequestMethods,
//     url: string,
//     param?: AxiosRequestConfig,
//     axiosConfig?: HttpRequestConfig
//   ): Promise<T>;
//   post<T, P>(
//     url: string,
//     params?: T,
//     config?: HttpRequestConfig
//   ): Promise<P>;
//   get<T, P>(
//     url: string,
//     params?: T,
//     config?: HttpRequestConfig
//   ): Promise<P>;
// }
